<?php
header ( "Content-Type: text/html; charset=UTF-8" );
$str='123,23,13424,15234';
echo rtrim($str,',');
$str = 'i love you.do you love me?';
$str = preg_replace(array('/!(^[^\x80-\xff]+$)/', '/\+|\-|\*|\//'), array('', ','), $str);
echo $str;

exit;
echo intval((time()-1351793330)/(60*60*24));

exit;

if($_GET['type'] == 2){
	$qtarr = file_get_contents('http://42.121.84.114/api/vehicle/getchannelsV2?rid=96&id=1086&key=625c2609f9e5fbcdefadcdb296b60d00&nocache=1');
}else{
	$qtarr = file_get_contents('http://42.121.84.114/api/vehicle/getchannelsV2?rid=0&id=1086&key=625c2609f9e5fbcdefadcdb296b60d00&nocache=1');
}
$qtarr = json_decode($qtarr);

$num=1;
echo "<pre>";
var_dump($qtarr->channels);echo "<pre>";exit;
foreach ($qtarr->channels as $value){
	var_dump($value->region);
	$num++;
}
echo $num;exit;
echo "<pre>";
echo "<null!='FM'>".(null!='FM');
echo null!='FM';
exit;

$x=6;

switch(1){
	case $x>5 && $x>1:
		echo "切";
	case $x>10:
		echo "靠"; 
	default:
	echo "sun of the beach!";
}

// cho (int) 'abcd';
echo !"";
$string = 'aaa'; echo $string{1};exit;

$str = "abcdefghigk";

$str = 'abcdfefsagasg';
$i = 0;

while ( isset ( $str {$i} ) && $rstr = $str {$i} ) {
	echo $rstr;
	echo "<br>";
	$i ++;
}

/*
 * foreach($arr as $key => $value){ echo $value; }
 */

/* $num = 'hd'>>1;
var_dump($num); */
exit ();
while ( $num = 49216738 >> 1 ) {
	if ($num > 0) {
		echo $num;
		echo "<br>";
		echo $num & 1;
		echo "<br>";
	} else {
		break;
	}
}
// cho 1101110011&1;
exit ();

echo in_array ( 0, array ('a', 'b' ) );

exit ();

echo strtotime ( '10:00' );
echo "<br>";
echo strtotime ( '11:01' );
echo "<br>";
echo time ();

exit ();

$str = '<?xml version="1.0" encoding="GBK"?><application><message><spid>cmcc-2000</spid><spcode>10662000</spcode><toicp>518</toicp><node>beijing</node><feecode>XXXDLY</feecode><feeprice>100</feeprice><feetype>ITEM</feetype><product>fcoop_ysx</product><feecategory>null</feecategory><channel>Fcoop_YCGK_HZ</channel><mobile>123</mobile><linkid>11551913749330100534</linkid><simulate>false</simulate><format>0</format><content>rskl</content><isprovision>false</isprovision><issubscribe>false</issubscribe><createDate>2012-09-13 11:55:20</createDate></message></application>';
$xml_obj = simplexml_load_string ( $str );

echo $backstr = "0x610x300x1C";
echo $back2str = "0x610x320x1C";

// BOX下发

$fid ['0x01'] = array ("0x10", "0x11", "0x12", "0x14", "0x15", "0x1e" );
$fid ['0x03'] = array ('0x10', '0x11', '0x15', '0x16', '0x1e' );
$fid ['0x02'] = array ('0x15', '0x1e' );
$fid ['0x11'] = array ('0x10', '0x11', '0x1e' );
$fid ['0x09'] = array ('0x10', '0x11', '0x15', '0x1e' );
$fid ['0x0A'] = array ('0x10', '0x11', '0x18', '0x1e' );
$fid ['0x0C'] = array ('0x10', '0x11', '0x12', '0x13', '0x14', '0x15', '0x16', '0x17', '0x18', '0x19', '0x1a', '0x1e' );
$fid ['0x0D'] = array ('0x10', '0x11', '0x12', '0x13', '0x14', '0x15', '0x16', '0x1a', '0x1e' );
$fid ['0x0E'] = array ('0x10', '0x11', '0x12', '0x13', '0x14', '0x15', '0x16', '0x17', '0x18', '0x19', '0x1a', '0x1e' );
$fid ['0x0F'] = array ('0x10', '0x11', '0x12', '0x13', '0x14', '0x15', '0x16', '0x17', '0x18', '0x19', '0x1a', '0x1e' );
$fid ['0x04'] = array ('0x1d' );

foreach ( $fid as $key => $value ) {
	
	// TTP协议内置信息
	$HttpMidArray = array ('0x11' => '时间', '0x12' => '安全气囊', '0x14' => '碰撞翻车', 'vehicle_status' => '点火状态', '0x13' => '档位', '0x19' => '轮胎胎压', '0x15' => '车门窗灯', '0x17' => '车内温度', 'engine coolant temperature' => '引擎冷却剂温度', '0x16' => '油量', 'engine speed' => '引擎转速', '0x18' => '车速', 

	'0x1a' => '刹车片信息,制动液信息,玻璃水信息,内部电池充电次数' );
	
	echo $key . ":";
	echo "<br>";
	$Handle = $value;
	foreach ( $Handle as $key => $value ) {
		if (isset ( $HttpMidArray [$value] )) {
			unset ( $HttpMidArray [$value] );
		}
	}
	echo "<pre>";
	/*
	 * print_r(implode('<>',array_values($HttpMidArray)));
	 * print_r(implode('<>',array_keys($HttpMidArray)));
	 */
	print_r ( $HttpMidArray );
	echo "</pre>";
}
echo "<br>";
echo "<br>";
echo "<br>";
echo "<br>";
echo "<br>";
echo $time = dechex ( time () - strtotime ( '2000-01-01 00:00:00' ) );
$strlen = strlen ( $time );
$string = '';

for($i = 0; $i < strlen ( $time ); $i += 2) {
	$string .= str_pad ( substr ( $time, $i, 2 ), 2, '0', STR_PAD_LEFT );
}
echo "<br>";
echo $string;

$str = "4C534A413136453958414741313437314325E8C8D3BE69ED321D0030301C";
$str = "4C534A413136453958414741313437314325E8C8D3BE69ED321D0030301C";
$src = "";
echo "<br>";
var_dump ( $str );
for($i = 0; $i < strlen ( $str ); $i ++) {
	// 字符串每个字符串拆分成一个字符，ord函数将字符转成ASCII值，dechex将ASCII值转为16进制数字，2位不足补齐0 拼接字符串0x
	$src .= "0x" . (substr ( $str, $i, 2 ));
}

echo $src;













/* $msg = "world";
 $callback = function ($var) use ($msg) {
echo $var,$msg;
};


$callback('hello ');

echo "<br>";
echo "10+7&~7".(10+7&~7);
echo "<br>";
echo "~7:".~7;
echo "<br>";
echo "17&-8:".(17&-8);
*/
